<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        var a = table.render({
            elem: '#currentTableId',
            url: '../../api/log?method=getAllLog',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                , statusCode: 200 //规定成功的状态码，默认：0
                , msgName: 'msg' //规定状态信息的字段名称，默认：msg
                , countName: 'count' //规定数据总数的字段名称，默认：count
                , dataName: 'data' //规定数据列表的字段名称，默认：data
            }, parseData: function (res) { //res 即为原始返回的数据
                console.log(res);
                if (res.code === 302) {
                    window.location = "../../login.html";
                    return;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            },
            cols: [[
                {field: 'userId', width: 100, title: '用户ID', sort: true},
                {field: 'userName', width: 120, title: '用户名', sort: true},
                {field: 'nickName', width: 120, title: '用户昵称', sort: true},
                {field: 'email', width: 200, title: '用户邮箱', sort: true},
                {field: 'phoneNumber', width: 160, title: '手机号码'},
                {
                    field: 'userType', width: 100, title: '用户类型', templet: function (d) {
                        var userType = d.userType;
                        if (userType == 0) {
                            return "管理员";
                        } else {
                            return "普通用户";
                        }
                    }
                },
                {field: 'msg', width: 160, title: '日志信息', sort: true},
                {field: 'logIp', width: 160, title: '登录ip', sort: true},
                {field: 'logTime', width: 160, title: '日志时间', sort: true},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line'
        });
    });

</script>
    </body>
</html>